package com.example.crm.config;

import com.example.crm.web.interceptor.AuthorizationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lenovo
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    private String[] excludePathPatterns;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        //拦截路径规则
        String[] pathPatterns = {"/**"};
        //排除路径规则
        String[] excludePathPatterns = {"/","/index","/login","/dologin","/css/**","/fonts/**","/images/**","/js/**","/localcss/**","/localjs/**"};
        //注册拦截器
        registry.addInterceptor(new AuthorizationInterceptor())
                //添加路径规则
                .addPathPatterns(pathPatterns)
                .excludePathPatterns(excludePathPatterns);
    }
}